// var arr = [2,2,1];
var arr = [4,1,2,1,2];
/**
 * @param {number[]} nums
 * @return {number}
 */
 var singleNumber = function(nums) {
   var result = 0
  for(var value of nums) {
    result = result ^ value
  }
  return result;
};

console.log(singleNumber(arr))